import Vue from "vue";
import VueRouter from "vue-router";
import Login from "../components/Login.vue";
import Home from "../components/Home.vue";
import ym_check from "../components/ym-check.vue";
import ym_record from "../components/ym-record.vue";
import register from "../components/register.vue";
Vue.use(VueRouter);

const routes = [{
    path: "/",
    redirect: "/login"
  },
  {
    path: "/login",
    component: Login
  },
  {
    path: "/register",
    component: register
  },
  {
    path: "/Home",
    component: Home,
    redirect: "/Home/ym-check",
    children: [{
        path: "/Home/ym-check",
        component: ym_check
      },
      {
        path: "/Home/ym-record",
        component: ym_record
      },
      // { path: "/Test", component: Test },
    ]
  }

  // {
  //   path: '/',
  //   name: 'Home',
  //   component: Home
  // },
  // {
  //   path: '/about',
  //   name: 'About',
  //   // route level code-splitting
  //   // this generates a separate chunk (about.[hash].js) for this route
  //   // which is lazy-loaded when the route is visited.
  //   component: () => import(/* webpackChunkName: "about" */ '../views/About.vue')
  // }
];

const router = new VueRouter({
  routes
});
// router.beforeEach((to, from, next) => {
//   if (to.path === '/login') return next()
//   const tokenstr = window.sessionStorage.getItem('token')
//   // if(!tokenstr ) return next('/login');
//   next()
// })
export default router;
